package com.example.android_kakao;

import java.util.*;

import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;

public class MainActivity extends Activity {

	EditText addTextView;
	Button imageBtn;
	MyAdapter mAdapter;
	CheckBox mCheck;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		ListView listView = (ListView) findViewById(R.id.listView);

		ArrayList<MyData> datas = new ArrayList<MyData>();
		mAdapter = new MyAdapter(this, datas);
		listView.setAdapter(mAdapter);

		addTextView = (EditText) findViewById(R.id.msg_EditText);
		mCheck = (CheckBox) findViewById(R.id.checkBox);

		Button addBtn = (Button) findViewById(R.id.send_Btn);
		addBtn.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {
				// TODO Auto-generated method stub
				String msg = addTextView.getText().toString();
				if (msg.length() < 1)
					return;
				if (mCheck.isChecked()) {
					mAdapter.add(new SendMsgData(msg));
				} else {
					mAdapter.add(new ReciveMsgData(msg, "현주씨"));
				}
				addTextView.setText("");
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
